import request from '@/utils/request'

export function login(param) {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/admin/login',
    method: 'post',
    data: param
  })
}

export function getInfo(token) {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/admin/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/admin/logout',
    method: 'post'
  })
}

export function getAllAdmin() {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/admin/getAllAdmin',
    method: 'get'
  })
}

export function add(param) {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/admin/add',
    method: 'post',
    data: param
  })
}

export function update(param) {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/admin/modify',
    method: 'post',
    data: param
  })
}

export function remove(id) {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/admin/remove',
    method: 'get',
    params: { id }
  })
}

// 获得全部审核状态的帖子
export function fetchAllUserList(query) {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/user/alluser',
    method: 'get',
    params: query
  })
}

// 获得全部审核状态的帖子
export function disableUser(id) {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/user/disableUser',
    method: 'get',
    params: { id }
  })
}

// 获取管理员登录日志
export function fetchLoginLogList(param) {
  return request({
    baseURL: process.env.VUE_APP_ADMIN_API,
    url: '/admin/allLoginLog',
    method: 'get',
    params: param
  })
}

